import UIKit
extension UIColor {
    convenience init(hex: Int, alpha: CGFloat = 1.0) {
        self.init(red: (CGFloat(hex >> 16 & 0xff) / 255), green: (CGFloat(hex >> 8 & 0xff) / 255), blue: (CGFloat(hex & 0xff) / 255), alpha: alpha)
    }
    
    //返回随机颜色
    class var randomColor: UIColor {
        get {
            let red = CGFloat(arc4random()%256)/255.0
            let green = CGFloat(arc4random()%256)/255.0
            let blue = CGFloat(arc4random()%256)/255.0
            return UIColor(red: red, green: green, blue: blue, alpha: 1.0)
        }
    }
}
